package com.ruoyi.app.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.app.mapper.AppArticleMapper;
import com.ruoyi.app.domain.AppArticle;

/**
 * 文章管理Service业务层处理
 *
 * @author wujiyue
 * @date 2019-10-28
 */
@Service
public class AppArticleService {
    @Autowired
    private AppArticleMapper articleMapper;

    /**
     * 查询文章管理
     *
     * @param id 文章管理ID
     * @return 文章管理
     */
    public AppArticle selectArticleById(String id) {
        AppArticle article = articleMapper.selectArticleById(id);
        Map<String, Object> m = articleMapper.getArticleContent(id);
        if (m != null) {
            article.setContent(String.valueOf(m.get("content")));
            article.setContent_markdown_source(String.valueOf(m.get("content_markdown_source")));
        }
        return article;
    }

    /**
     * 查询文章管理列表
     *
     * @param article 文章管理
     * @return 文章管理
     */
    public List<AppArticle> selectArticleList(AppArticle article) {
        List<AppArticle> articles = articleMapper.selectArticleList(article);
        return articles;
    }


    public int upVote(String id) {
        return articleMapper.upVote(id);
    }

    public int articleLook(String id) {
        return articleMapper.articleLook(id);
    }


}
